import { Behaviour } from "../engine/Behaviour";
import { BitmapRenderer } from "../engine/BitmapRenderer";
import { boolean } from "../engine/validators/boolean";
import { number } from "../engine/validators/number";
import { string } from "../engine/validators/string";
import { binding, Binding, makeBinding } from "./Binding";
import { RigidBody } from "./RigidBody";
import { SceneChange } from "./SceneChange";

export class PortalBinding extends Binding {



    @boolean()
    @binding((prefabRoot, value) => {
        prefabRoot.children[0].getBehaviour(SceneChange).isSatisfied = value;
    })
    isSatisfied: boolean

    @number()
    @binding((prefabRoot, value) => {
        prefabRoot.children[0].getBehaviour(BitmapRenderer).source = value;
    })
    destination: number


    @string()
    @binding((prefabRoot, value) => {
        prefabRoot.children[0].getBehaviour(BitmapRenderer).source = value;
    })
    imageSource: string

    @number()
    @binding((prefabRoot, value) => {
        prefabRoot.getBehaviour(RigidBody).x = value;
    })
    x: number;

    @number()
    @binding((prefabRoot, value) => {
        prefabRoot.getBehaviour(RigidBody).y = value;
    })
    y: number;


    constructor() {
        super();
        makeBinding(this)
    }
}